package com.hliushi.learn.bean;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @ClassName User
 * @Description TODO
 * @Author hliushi
 * @Date 2021/7/5 20:10
 * @Version V1.0
 **/
@ApiModel(value = "用户实体类")      // 该注解作用于实体类, 表示对类进行说明, 用于参数用实体类接收
public class User {

    @ApiModelProperty(value = "用户id")   // 该注解用于类汇总属性, 表示对model属性的说明或者数据操作更改
    private Long id;
    @ApiModelProperty(value = "用户账号")
    private String username;


    /**
     * json数据处理
     * . @JsonIgnore 作用于类的属性上, 用于过滤掉特定字段不返回或者不解析
     * .  作用是: "实体类向前台返回数据时用来忽略不想传递给前台的属性或接口"
     * {ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}
     * #
     * . @JsonIgnoreProperties 作用和上面的@JsonIgnore一样, 作用域不同, 作用于类上面
     * # 等同于  在User类上加上注解 @JsonIgnoreProperties(value = "{password}")
     */
    @JsonIgnore
    @ApiModelProperty(value = "用户密码")
    private String password;

    public User(Long id, String username, String password) {
        this.id = id;
        this.username = username;
        this.password = password;
    }

    public User() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
